package com.qf.qfcenterservice.api;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.qf.common.feigns.UserApi;
import com.qf.common.model.QfUser;
import com.qf.qfcenterservice.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/user")
public class UserFeignApi implements UserApi {

    @Autowired
    private UserService userService;

    @Override
    @GetMapping("/findByUsername")
    public QfUser findByUsername(@RequestParam("username") String username) {

        Wrapper<QfUser> qw = Wrappers.lambdaQuery(QfUser.class)
                .eq(QfUser::getUserName,username);

        QfUser qfUser = userService.getOne(qw);

        return qfUser;
    }
}
